package kudu;

import org.apache.kudu.client.*;

public class selectDemo {
    public static void main(String[] args) {
        //1、获取client
        String masterAddr="linux122";
        KuduClient.KuduClientBuilder kuduClientBuilder = new KuduClient.KuduClientBuilder(masterAddr);
        kuduClientBuilder.defaultSocketReadTimeoutMs(5000);
        KuduClient client = kuduClientBuilder.build();

        try {
            //2、获取Scanner
            KuduTable table = client.openTable("student");
            KuduScanner scanner = client.newScannerBuilder(table).build();
            //3、从Scanner中循环遍历数据
            while (scanner.hasMoreRows()){
                for(RowResult rowResult:scanner.nextRows()){
                    int id = rowResult.getInt("id");
                    String name = rowResult.getString("name");
                    System.out.println("id:"+id+",name"+name);
                }
            }
        } catch (KuduException e) {
            e.printStackTrace();
        } finally {
            try {
                client.close();
            } catch (KuduException e) {
                e.printStackTrace();
            }
        }

    }
}
